<%@ page import="com.lms.pojo.User" %>
<%@ page import="com.github.pagehelper.PageInfo" %><%--
  Created by IntelliJ IDEA.
  User: hsy
  Date: 2023/6/3
  Time: 10:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <title>查看所有用户信息</title>
  <link rel="stylesheet" href="css/showAllUser.css">
</head>

<body>
<%--共同侧边栏--%>
<%@ include file="sidebar.jsp" %>
<h1><a href="userAdd.jsp">添加用户</a></h1>
<table border="1" cellspacing="0" cellpadding="5">

  <tr>
    <th>用户编号</th>
    <th>用户名</th>
    <th>用户邮箱</th>
    <th>操作</th>
  </tr>
  <%
    //pageInfo封装了很多信息
    PageInfo<User> pageInfo = (PageInfo<User>) request.getAttribute("pageInfo");
    for (User user : pageInfo.getList()) {
  %>
  <tr>
    <td><%=user.getUserID()%>
    </td>
    <td><%=user.getUserName()%>
    </td>
    <td><%=user.getEmail()%>
    </td>
    <td>
      <a href="<%=request.getContextPath()%>/UserDeleteServlet?UserID=<%=user.getUserID()%>" onclick="return confirm('确定要删除吗？')">删除</a>
      <a href="<%=request.getContextPath()%>/UserModify.jsp?UserID=<%=user.getUserID()%>&UserName=<%=user.getUserName()%>&Email=<%=user.getEmail()%>">修改</a>
    </td>
  </tr>
  <%}%>
</table>
<%
  if (pageInfo.getList() == null || pageInfo.getList().size() == 0 || pageInfo.getList().equals("")) {
%>
<h3>未找到数据</h3>
<%}%>
<a href="<%=request.getContextPath()%>/UserServlet?page=1">首页</a>
<%-- 检查上一页 --%>
<% if (pageInfo.getPrePage() > 0) { %>
<a href="<%=request.getContextPath()%>/UserServlet?page=<%=pageInfo.getPrePage()%>">上一页</a>
<% }%>
<%-- 检查下一页--%>
<% if (pageInfo.getNextPage() > 0) { %>
<a href="<%=request.getContextPath()%>/UserServlet?page=<%=pageInfo.getNextPage()%>">下一页</a>
<% } %>
<a href="<%=request.getContextPath()%>/UserServlet?<%="page=" + pageInfo.getPages()%>">尾页</a>
总记录:<%=pageInfo.getTotal()%>条
当前第 <%=pageInfo.getPageNum()%>页
</body>
</html>
